package charpter01_basic.lession05_impl_producter_consumer;

import charpter01_basic.lession05_impl_producter_consumer.my_queue.MyBlockingQueue;

/**
 * 使用 wait/notify 实现生产者消费者模式
 */
public class ProducterConsumer3 {

    public static void main(String[] args) {
        MyBlockingQueue myBlockingQueue = new MyBlockingQueue(16);
        new Thread(() -> {
            while (true) {
                myBlockingQueue.put(1);
                System.out.println("put 1 task, size="+ myBlockingQueue.size());
            }
        }).start();

        new Thread(() -> {
            while (true) {
                myBlockingQueue.take();
                System.out.println("take 1 task, size="+ myBlockingQueue.size());
            }
        }).start();
    }
}
